package com.tennis.tennisreservation.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.Customizer;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.web.SecurityFilterChain;

/**
 * Spring Security 配置类：放开所有权限
 */
@Configuration
public class SecurityConfig {

    @Bean
    public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
        http
            .csrf(csrf -> csrf.disable()) // 关闭 CSRF 校验
            .authorizeHttpRequests(auth -> auth
                .anyRequest().permitAll() // 放开所有接口
            )
            .httpBasic(Customizer.withDefaults()); // 使用基本认证（可关闭）

        return http.build();
    }
}
